package com.zcmob.web.admanagement.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zcmob.web.admanagement.db.AppDao;
import com.zcmob.web.admanagement.vo.AdUser;
import com.zcmob.web.admanagement.vo.AppInfo;

/**
 * Servlet implementation class for Servlet: AppListSerlvet
 *
 */
 public class AppListSerlvet extends com.zcmob.web.admanagement.servlet.ZcMobServlet {
   static final long serialVersionUID = 1L;
   
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public AppListSerlvet() {
		super();
	}   	

    @Override
    protected void handle(HttpServletRequest request, HttpServletResponse response) {

        
        AdUser aduser = (AdUser)request.getSession().getAttribute("aduser");
        
        List<AppInfo> result = AppDao.getInstance().getAppsByUserId(aduser.getId());
        
        request.setAttribute("applist", result);
        // 默认进入applist页面
        request.getSession().setAttribute("channel", "list");
        
        RequestDispatcher rd = request.getRequestDispatcher("/ad_workbench.jsp");
        try {
            rd.forward(request, response);
        } catch (ServletException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }   	  	    
}